# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libksba
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.4.0
pkgrel=1
pkgdesc="A CMS and X.509 access library (mingw-w64)"
arch=('any')
license=('GPL')
url="https://www.gnupg.org/related_software/libksba/"
depends=("${MINGW_PACKAGE_PREFIX}-libgpg-error")
options=('strip' 'staticlibs')
source=("https://gnupg.org/ftp/gcrypt/${_realname}/${_realname}-${pkgver}.tar.bz2"{,.sig}
        0001-fix-def.mingw.patch)
#These might be signed by any of these keys https://gnupg.org/signature_key.html
validpgpkeys=('D8692123C4065DEA5E0F3AB5249B39D24F25E3B6'
              '46CC730865BB5C78EBABADCF04376F3EE0856959'
              '031EC2536E580D8EA286A9F22071B08A33BD3F06'
              'D238EA65D64C67ED4C3073F28A861B1C7EFD60D9')
sha256sums=('bfe6a8e91ff0f54d8a329514db406667000cb207238eded49b599761bfca41b6'
            'SKIP'
            '0252e688224bac2f008100a7c9139cd79b3c1b8321529ef672fea2d08206598a')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0001-fix-def.mingw.patch
}

build() {
  [ -d ${srcdir}/build-${MINGW_CHOST} ] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make
}

check() {
   cd ${srcdir}/build-${MINGW_CHOST}
   make check
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}
  make -j1 DESTDIR=${pkgdir} install
}
